class Solution(object):
    def missingNumber(self, arr):
        """
        :type arr: List[int]
        :rtype: int
        """
        for i in range(1, len(arr) - 1):
            if abs(arr[i] - arr[i - 1]) < abs(arr[i] - arr[i + 1]):
                return 2 * arr[i] - arr[i - 1]
            else:
                if abs(arr[i] - arr[i - 1]) > abs(arr[i] - arr[i + 1]):
                    return 2 * arr[i] - arr[i + 1]
        return arr[0]